import 'dart:io';

Future<void> describeFlybyObjects(List<String> flybyObjects) async {
  try {
    for (final object in flybyObjects) {
      var description = await File('$object.txt').readAsString();
      print(description);
    }
  } on IOException catch (e) {
    print('Could not describe object: $e');
  } finally {
    flybyObjects.clear();
  }
}

void main() async {
  var flybyObjects = ['Jupiter', 'Saturn', 'Uranus'];

  print('开始描述飞越天体...');
  try {
    await describeFlybyObjects(flybyObjects);
  } catch (e) {
    print('发生未捕获的异常: $e');
  }
  print('程序结束');

  print('飞越天体列表是否为空: ${flybyObjects.isEmpty}');
}
